package cn.tedu.rms.dish.controller;

import cn.tedu.rms.base.response.JsonResult;
import cn.tedu.rms.dish.pojo.dto.DishQuery;
import cn.tedu.rms.dish.pojo.dto.DishSaveParam;
import cn.tedu.rms.dish.pojo.vo.DishVo;
import cn.tedu.rms.dish.service.impl.DishService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("v1/dish")
@Slf4j
public class DishController {
    @Autowired
    private DishService dishService;
    @GetMapping("select")
    public JsonResult select(DishQuery dishQuery){
        log.debug("查询菜品:参数={}",dishQuery);
        List<DishVo> list= dishService.selectDish(dishQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult save(DishSaveParam dishSaveParam){
        log.debug("添加菜品:参数={}",dishSaveParam);
        dishService.save(dishSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        log.debug("删除菜品:参数={}",id);
        dishService.deleteById(id);
        return JsonResult.ok();
    }
    @PostMapping("update/status/{id}/{status}")
    public JsonResult updateStatus(@PathVariable Long id,@PathVariable String status){
        log.debug("修改菜品状态:参数={},{}",id,status);
        dishService.updateStatus(id,status);
        return JsonResult.ok();
    }

}
